<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <base href="<%=basePath%><%!private Object basePath;%>">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>“墨趣”书城后台管理</title>
    <meta name="description" content="这是一个图书管理页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="back/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="back/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="back/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="back/assets/css/admin.css">
    <link rel="stylesheet" href="back/assets/css/app.css">
</head>

<body data-type="generalComponents">
  <div>
        <ol class="am-breadcrumb">
            <li><a href="back/right.jsp" class="am-icon-home">首页</a></li>
            <li class="am-active">图书列表</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    图书列表
                </div>
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span><a href="back/book_add.jsp"> 新增</a> </button>
                               <%-- <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>--%>
                                <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                            </div>
                        </div>
                    </div>

                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                            <input type="text" class="am-form-field">
                            <span class="am-input-group-btn">
                                    <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" id="but" type="button"></button>
                                </span>
                        </div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12">
                        <form class="am-form">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                    <th class="table-id">ID</th>
                                    <th class="table-title">类别</th>
                                    <th class="table-author am-hide-sm-only">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;图书名</th>
                                    <th class="table-date am-hide-sm-only">图书价格</th>
                                    <th class="table-set">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;操作</th>
                                </tr>
                                </thead>
                                <tbody id="nbody">
                                  <c:forEach items="${booklist}" var="book">
                                    <tr>
                                        <td><input type="checkbox"></td>
                                        <td>${book.id}</td>
                                        <td><a>${book.categoryid.typename}</a></td>
                                        <td class="am-hide-sm-only">${book.bname}</td>
                                        <td class="am-hide-sm-only">
                                           ${book.price}
                                        </td>
                                        <td>
                                            <div class="am-btn-toolbar">
                                                <div class="am-btn-group am-btn-group-xs">
                                                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary"><a href="/books/getbyid.action?bid=${book.id}&n=0"> <span class="am-icon-pencil-square-o"></span> 查看详情</a></button>
                                                    <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><a href='/books/getbyid.action?bid=${book.id}&n=1'> <span class="am-icon-trash-o"></span> 编辑</a></button>
                                                    <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><a href='/books/del.action?bid=${book.id}'> <span class="am-icon-trash-o"></span> 删除</a></button>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                            <div class="am-cf">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <li class="am-disabled"><a href="#">«</a></li>
                                        <li class="am-active"><a href="#">1</a></li>
                                        <li><a href="#">2</a></li>
                                        <li><a href="#">3</a></li>
                                        <li><a href="#">4</a></li>
                                        <li><a href="#">5</a></li>
                                        <li><a href="#">»</a></li>
                                    </ul>
                                </div>
                            </div>
                            <hr>

                        </form>
                    </div>

                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>

<script src="back/assets/js/jquery.min.js"></script>
<script src="back/assets/js/amazeui.min.js"></script>
<script src="back/assets/js/app.js"></script>
<script src="back/assets/js/jquery-1.12.4.js"></script>
<script>
    $(function(){

        $.getJSON("books/list.action","",function(res){

            for(var i=0;i<res.length;i++){
                var newtr=$("<tr></tr>");
                newtr.append("<td><input type=\"checkbox\"></td>");
                newtr.append("<td>"+res[i].id+"</td>");
                newtr.append("  <td><a>"+res[i].categoryid.typename+"</a></td>");
                newtr.append("<td class=\"am-hide-sm-only\">"+res[i].bname+"</td>");
                newtr.append("<td class=\"am-hide-sm-only\">"+res[i].price+" </td>");
                newtr.append("<td><div class=\"am-btn-toolbar\"><div class=\"am-btn-group am-btn-group-xs\">" +
                    "<button class=\"am-btn am-btn-default am-btn-xs am-text-secondary\"><a href=\"/books/getbyid/0.action?bid="+res[i].id+"> <span class=\"am-icon-pencil-square-o\"></span> 查看详情</a></button>" +
                    "<button class=\"am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only\"><a href='/books/getbyid/1.action?bid="+res[i].id+"'> <span class=\"am-icon-trash-o\"></span> 编辑</a></button>" +
                    "<button class=\"am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only\"><a href='/books/del.action?bid="+res[i].id+"'> <span class=\"am-icon-trash-o\"></span> 删除</a></button>" +
                    "</div> </div> </td> ");
                $("#nbody").append(newtr);
            }
        });
    })
</script>
</body>

</html>

